package com.liyu.iblog.web;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.liyu.iblog.enums.ActiveTab;
import com.liyu.iblog.service.HomeService;

@Controller
@RequestMapping("/about")
public class AboutController {
    
private static final Logger logger = LoggerFactory.getLogger(AboutController.class);
    
    private HomeService homeService;
    
    @Autowired
    public AboutController(HomeService homeService) {
        this.homeService = homeService;
    }

    @RequestMapping(method = RequestMethod.GET)
    public String loadAboutPage(Model model) {
        logger.debug("loading about page...");
        Map<String, Object> infoMap = homeService.gatherInfoForHomePage();
        model.addAttribute("blogs", infoMap.get("blogs"));
        model.addAttribute(ActiveTab.ABOUT_TAB.toString(), true);
        return "about";
    }
    
}
